package com.example.seckill.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @program: seckill
 * @description: 公共返回对象
 * @author: KingCrimson
 * @create: 2022-08-06 20:38
 **/

@Data
@NoArgsConstructor
@AllArgsConstructor
public class RespBean {

    //状态码
    private long code;

    //消息
    private String message;

    //对象
    private Object object;


    //成功的返回结果
    public static RespBean success(){
        return new RespBean(RespBeanEnum.SUCCESS.getCode(), RespBeanEnum.SUCCESS.getMessage(), null);
    }

    //成功的返回结果(带对象)
    public static RespBean success(Object object){
        return new RespBean(RespBeanEnum.SUCCESS.getCode(), RespBeanEnum.SUCCESS.getMessage(), object);
    }

    //失败的返回结果
    public static RespBean error(RespBeanEnum respBeanEnum){
        return new RespBean(respBeanEnum.getCode(), respBeanEnum.getMessage(), null);
    }

    //失败的返回结果(带对象)
    public static RespBean error(RespBeanEnum respBeanEnum,Object object){
        return new RespBean(respBeanEnum.getCode(), respBeanEnum.getMessage(), object);
    }


}
